#include <iostream>
#include <memory>
#include "tcp_server.hpp"
#include "command.hpp"

//./server serverport
int main(int argc, char *argv[])
{
    if (argc != 2) // if (argc != 3)
    {
        std::cout << "Usage: ./xxx serverport" << std::endl; // std::cout << "Usage: ./xxx serverip serverport" << std::endl;
        exit(-1);
    }
    uint16_t lockport = std::stoi(argv[1]);// std::string lockip = argv[1];

    Command com;
    std::unique_ptr<TcpServer> u_p = std::make_unique<TcpServer>(std::bind(&Command::HandlerCommand, &com, std::placeholders::_1, std::placeholders::_2), lockport);
    u_p->InitServer();
    u_p->Loop();

    return 0;
}